/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package beans;

import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author machine
 */
@Stateless
public class CalificacionFacade extends AbstractFacade<Calificacion> implements CalificacionFacadeLocal {
    @PersistenceContext(unitName = "videosJEE-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public CalificacionFacade() {
        super(Calificacion.class);
    }

    @Override
    public List<Calificacion> consultarCalificaciones(int idvideo) {
        
        Query q = em.createQuery( "SELECT c FROM Calificacion c WHERE c.idpeliculas.idpeliculas = "+idvideo+" " );
        
        
        return q.getResultList(); // or getSingleResult();
        
        
    }
    
}
